package Xiaofang;
import java.io.*;
import java.nio.charset.Charset;

public class Work002 {
//    public void replace(String fil1,String fil2){
//        BufferedReader reader=null;
//        BufferedWriter writer=null;
//        try {
//            FileInputStream fil=new FileInputStream(fil1);
//            try {
//                InputStreamReader is=new InputStreamReader(fil,"utf-8");
//                try {
//                    FileWriter fw=new FileWriter(fil2);
//                    reader=new BufferedReader(is);
//                    writer=new BufferedWriter(fw);
//                    String line=null;
//                    StringBuffer sb=new StringBuffer();
//                    while ((line=reader.readLine())!=null){
//                        sb.append(line);
//                    }
//                    String st=sb.toString().replace("金正恩","金三胖");
//                    writer.write(st);
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }finally {
//                    try {
//                        writer.close();
//                        reader.close();
//                        is.close();
//                        fil.close();
//                    } catch (IOException e) {
//                        e.printStackTrace();
//                    }
//                }
//            } catch (UnsupportedEncodingException e) {
//                e.printStackTrace();
//            }
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//    }
    public static void main(String[] args) {
        BufferedReader br=null;
        BufferedWriter bw=null;
        try {
            br=new BufferedReader(new FileReader("D:\\Xiaofang\\chaoxian.txt"));
            String line=null;
            StringBuffer sb=new StringBuffer();
            while (true){
                try {
                    if (!((line=br.readLine())!=null)) break;
                    sb.append(line);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            String ns=sb.toString().replace("金正恩","金三胖");
            try {
                bw=new BufferedWriter(new FileWriter("D:\\Xiaofang\\chaoxian.txt"));
                bw.write(ns);
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                try {
                    bw.close();
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
